new Vue({
    el: '#index-app',
    data: {
        //立即领取弹窗
        receiveShow: false,
        //进入花迦弹窗
        goInHuajia: false,
        //获取验证码的字，还有秒数
        getInviFont: '获取验证码',
        //从上往下优惠券控制
        offQuan: false,
        //用户登陆或注册输入的信息
        userInfo: {
            phone: '',
            invita: ''
        },
        //头部配置json
        heaIconJson: {
            left: './static/img/icon-list.png',
            middle: "<img src='./static/img/img-hea-hua.png' width='60px' height='46px' />",
            right1: './static/img/icon-search.png',
            right2: './static/img/icon-car.png'
        },
        //分类下面那一栏的数据
        goodsTitle: {
            title: 'SDJKHFJKSD FAHJKSDKF',
            notice: '今日推荐',
            month: 'Swedsfa',
            year: '2018',
            date: '26'
        },
        //恭喜你成为会员的弹窗提醒
        becomeVipFont: {
            title: '恭喜您成为会员',
            notice: '快去看看会员专属的优惠吧',
            img: './static/img/become-vip.png',
            sure: '我知道了'
        },
        //大图片的数据
        bigGoods: [{
            img: './static/img/c318da24a480c283e07160af28b1d6a7.jpg@0o_0l_750w_90q.jpg',
            title: '野兽派的迎新趴体，优惠狂欢不停歇',
            notice: '新人专享360元现金券，让你更愉快地买买买。'
        }, {
            img: './static/img/6f1ab73874f0a1b62ce59520da911ff1.jpg@0o_0l_750w_90q.jpg',
            title: '这个秋冬一定要有的“枫叶红',
            notice: 'INS网红用的都是这些'
        }],
        //商品数据
        goodsInfo: [{
            img: 'https://img.thebeastshop.com/image/20180918173031174479.jpg@4e_0o_0l_345h_330w_90q.jpg',
            badge: 'Bio-E',
            name: '天然柠檬麦卢卡酵素 500ml',
            price: '139.00',
            explain: '海外购'
        }, {
            img: 'https://img.thebeastshop.com/image/20180918173031174479.jpg@4e_0o_0l_345h_330w_90q.jpg',
            badge: 'Bio-E',
            name: '天然柠檬麦卢卡酵素 500ml',
            price: '139.00',
            explain: '海外购'
        }, {
            img: 'https://img.thebeastshop.com/image/20180918173031174479.jpg@4e_0o_0l_345h_330w_90q.jpg',
            badge: 'Bio-E',
            name: '天然柠檬麦卢卡酵素 500ml',
            price: '139.00',
            explain: '海外购'
        }, {
            img: 'https://img.thebeastshop.com/image/20180918173031174479.jpg@4e_0o_0l_345h_330w_90q.jpg',
            badge: 'Bio-E',
            name: '天然柠檬麦卢卡酵素 500ml',
            price: '139.00',
            explain: '海外购'
        }],
    },
    methods: {
        right1: function() {
            window.location.href = HREF + 'search.html';
        },
        right2: function() {
            window.location.href = HREF + 'my-shopping-car.html';
        },
        //获取验证码
        getInvi: function() {
            if (this.getInviFont != '获取验证码') {
                return;
            }
            var i = 60;
            var This = this;
            var time = setInterval(function() {
                This.getInviFont = i + 's';
                if (i-- <= 0) {
                    clearInterval(time);
                    This.getInviFont = '获取验证码';
                }
            }, 1000);
        },
        //立即领取会员  /  进入花迦
        goReceive: function(val) {
            if (!this.checkMobile(this.userInfo.phone)) {
                return;
            }
            var invita = this.userInfo.invita.trim();
            if (invita.length != 4) {
                _layer('请输入正确的验证码');
                return;
            }
            if (val == 'in') {
                //进入花迦
                this.goInHuaJiaEv();
            } else {
                //立即领取
                this.getVip();
            }
        },
        //进入花迦
        goInHuaJiaEv: function() {
            alert('进入花迦');
        },
        //立即领取
        getVip: function() {
            alert('立即领取');
        },
        //恭喜您成为会员，我知道了
        sureBecomeVip: function() {
            alert('我知道了');
            this.$refs.becomeVip.offShow = false;
        },
        //验证手机号正则
        checkMobile(sMobile) {
            if (!(/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(sMobile))) {
                _layer('请输入正确的手机号');
                return false;
            } else {
                return true;
            }
        },
        //点击领取券
        getQuan: function() {
            alert('领取券');
        }
    }
});